// import Router from 'vue-router'
import { UserLayout } from '@/layouts'
import { createRouter, createWebHistory } from 'vue-router'
// hack router push callback
// [解决 vue-router跳转相同路径报错 ]

// 纯静态路由配置项
const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import('@/views/user/Login')
      }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes: constantRouterMap
})
const originalPush = router.push
router.push = function push (location, onResolve, onReject) {
  if (onResolve || onReject) { return originalPush.call(this, location, onResolve, onReject) }
  return originalPush.call(this, location).catch((err) => err)
}
export default router
